<template>
	<view class="search">
		<view class="top">
			<span @click="back">返回</span>
			<u-search placeholder="请输入关键字" v-model="keyword" @search="search"></u-search>
		</view>
		<view class="sousuo">
			<div class="left">历史记录</div>
			<div class="right" @click="del">清楚全部</div>
		</view>
		<view v-for="(item,index) in query" :key="index">
			{{item}}
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				keyword:'',
				query:[],
				page:1
			}
		},
		methods: {
			back(){
				uni.navigateBack({
					delta:5
				})	
			},
			search(e){
				let query=uni.getStorageSync("query")|| []
				query.push(e)
				uni.setStorageSync("query",query)
				console.log(e);
				uni.navigateTo({
					url:`/pages/seachdetails/seachdetails?keyword=${e}`
				})
			},
			del(){
				uni.removeStorageSync("query")
			}
		},
		onShow() {
			this.query=uni.getStorageSync("query")
		},
		onLoad() {
			 
		}
	}
</script>

<style lang="scss">

.search{
	width: 100%;
	height: 100%;
	padding: 0 10px;
	box-sizing: border-box;
	.top{
		display: flex;
	}
	.sousuo{
		width: 100%;
		display: flex;
		justify-content: space-between;
	}
}
</style>
